/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package coalescent.cef.pui;

import cef.event.Event;
import cef.pui.EventConstructionException;
import cef.pui.EventImpl;
import cef.pui.pob.Builder;
import cef.pui.pob.BuilderException;

import coalescent.cef.event.CheckPhylogenyEvent;
import coalescent.cef.pui.pob.Builders;
import coalescent.phylogeny.CheckPPhylogenyAlgo;

import commons.core.ValueTypes;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

/**
 * Implements {@code CheckPhylogenyEvent} using the following properties: <ul> <li>{@code commons.builder.BinaryData.url
 * = bytearraylist:txt//URL }<a href="cef/pui/pob/doc-files/binary-data.txt">file format</a></li> <li>{@code
 * coalescent.builder.CheckPPhylogenyAlgo.algorithm}("GUSFIELD", "FOURGAMETES")</li> </ul>
 *
 * @author Susanta Tewari
 * @version 2.0.0
 * @history Created on 12/08/2010.
 * @since 1.3.0
 */
public final class CheckPhylogenyEventImpl extends EventImpl implements CheckPhylogenyEvent {

    /** Field description */
    private Builder<ValueTypes.ByteArrayList> dataBuilder;

    /** Field description */
    private Builder<CheckPPhylogenyAlgo> algorithmBuilder;

    /**
     * Constructs ...
     *
     *
     * @param props
     *
     * @throws EventConstructionException
     */
    public CheckPhylogenyEventImpl(Properties props) throws EventConstructionException {

        super(props);

        super.processEventProperties(getImplementedEventInterfaces());

        dataBuilder = cef.pui.pob.Builders.getBinaryDataBuilderFileBased(props);

        addBuilder(dataBuilder);

        algorithmBuilder = Builders.getPhylogenyAlgoBuilder(props);

        addBuilder(algorithmBuilder);
    }

    /**
     * Method description
     *
     *
     * @return
     */
    @Override
    protected List<Class<? extends Event>> getImplementedEventInterfaces() {

        List<Class<? extends Event>> result = new ArrayList<>(2);

        result.add(CheckPhylogenyEvent.class);
        result.add(Event.class);

        return result;
    }

    /**
     * Method description
     *
     *
     * @return
     */
    @Override
    public CheckPPhylogenyAlgo getPhylogenyAlgorithm() {
        return algorithmBuilder.build();
    }

    /**
     * Method description
     *
     *
     * @return
     *
     * @throws BuilderException
     */
    @Override
    public ValueTypes.ByteArrayList getData() throws BuilderException {
        return dataBuilder.build();
    }
}
